class Solution {
    public String reverseLeftWords(String s, int n) {
        n = n % s.length();
        String str1 = s.substring(n);
        String str2 = s.substring(0, n);
        return str1 + str2;
    }

    //剑指 Offer 20. 表示数值的字符串
    public static boolean isNumber(String s) {
        String str = s.trim();
        char[] ch = str.toCharArray();
        if (ch.length == 0) {
            return false;
        }
        if (ch.length == 1 && ch[0] == '.' || ch[0] == 'E' || ch[0] == 'e' ||
                ch[ch.length - 1] == 'e' || ch[ch.length - 1] == 'E') {
            return false;
        }
        if (ch[ch.length - 1] == '+' || ch[ch.length - 1] == '-') {
            return false;
        }
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < ch.length; i++) {
            if (ch[i] == 'e' || ch[i] == 'E') {
                count1++;
            }
            if ((ch[i] == '-' || ch[i] == '+' || ch[i] == '.') &&
                    i + 1 < ch.length - 1 && (ch[i + 1] == '-' || ch[i + 1] == '+' || ch[i + 1] == '.')) {
                return false;
            }

            if (ch[i] == '.') count1++;
            if (ch[i] == '-' || ch[i] == '+') count2++;
            if (count1 >= 2) return false;
            if (ch[0] >= '0' && ch[0] <= '9' && count2 != 0) return false;

            if (ch[i] != '.' && ch[i] != 'e' && ch[i] != 'E' && ch[i] != '+' && ch[i] != '-' &&
                    (ch[i] < '0' || ch[i] > '9')) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        isNumber("-1E-16");
    }
}